package ${commonPackageName}.entity.resp;


import ${commonPackageName}.enums.ExceptionEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * 
 * @author lizihao
 *
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel("响应消息")
public class Result {

    @ApiModelProperty(value = "响应编码", example = "0")
    private int resultCode;

    @ApiModelProperty(value = "响应消息", example = "执行成功")
    private String resultDesc;
    @ApiModelProperty(value = "续期的token")
    private String newToken;

    public Result(int code, String desc) {
        this.resultCode = code;
        this.resultDesc = desc;
    }

    public static Result ok() {
        return new Result(ExceptionEnum.SUCCESS.getCode(), ExceptionEnum.SUCCESS.getMsg());
    }

    public static Result ok(String desc) {
        return new Result(ExceptionEnum.SUCCESS.getCode(), desc);
    }

    public static Result fail() {
        return new Result(ExceptionEnum.ALL_FAIL.getCode(), ExceptionEnum.ALL_FAIL.getMsg());
    }

    public static Result fail(String desc) {
        return new Result(ExceptionEnum.ALL_FAIL.getCode(), desc);
    }
    public static Result fail(ExceptionEnum exception) {
        return new Result(exception.getCode(), exception.getMsg());
    }
}
